package org.github.core.spring.restful.json;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * JSON of data.
 *
 * @param <T> data
 * @author JYD_XL
 * @see java.io.Serializable
 * @see java.util.function.Supplier
 */
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
public class JSONData<T> extends JSONBase implements JSON {
  /** 数据 */
  @Nullable
  private T data;

  @Override
  public String toString() {
    return super.toString();
  }

  /**
   * Generator.
   */
  @NotNull
  public static <T> JSONData<T> of() {
    return new JSONData<>();
  }

  /**
   * Generator.
   */
  @NotNull
  public static <T> JSONData<T> of(T data) {
    return new JSONData<>(data);
  }
}
